#!/bin/sh

MD5_FIL="/lib/modules/`uname -r`/md5"
OLD_MD5=

[ -e $MD5_FIL ] && OLD_MD5=`cat $MD5_FIL`

if [ -x /usr/bin/exbootimg ] ; then
	dd if=/dev/mmcblk3p1 of=/tmp/boot.img bs=1M count=6 > /dev/null 2>&1
	exbootimg -b /tmp/boot.img -m /tmp/module.tar.bz2 > /dev/null 2>&1
	NEW_MD5=`md5sum /tmp/module.tar.bz2 | cut -d " " -f 1`
fi

if [ x"$OLD_MD5" != x"$NEW_MD5" ] ; then
	echo "old check : $OLD_MD5"
	echo "new check : $NEW_MD5"
	echo "extract module..."
	rm -rf /lib/modules/*
	tar xf /tmp/module.tar.bz2 -C / > /dev/null 2>&1
	echo $NEW_MD5 > $MD5_FIL
	sync
fi
